
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Rectangle.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Rectangle)
{

	TEST(Area should be calculated for a rectangle: 2*3=6)
	{
		TypeLength length(2);
		TypeLength width(3);
		Rectangle rectangle(length,width);
		ASSERT_EQ(6, rectangle.getArea());
	}

	TEST(Perimeter should be calculated for a rectangle: (2+3)*2=10 )
	{
		TypeLength length(2);
		TypeLength width(3);
		Rectangle rectangle(length,width);
		ASSERT_EQ(10, rectangle.getPerimeter());
	}

	TEST(Area should be calculated for a square: 2*2=4)
	{
		TypeLength length(2);
		Rectangle rectangle(length);
		ASSERT_EQ(4, rectangle.getArea());
	}

	TEST(Perimeter should be calculated for a square: 2*4=8)
	{
		TypeLength length(2);
		Rectangle rectangle(length);
		ASSERT_EQ(8, rectangle.getPerimeter());
	}

	TEST(Area should be calculated for a rectangle: 2.123*3.128=6.61)
	{
		TypeLength length(2.123);
		TypeLength width(3.128);
		Rectangle rectangle(length,width);
		ASSERT_EQ(6.61, rectangle.getArea());
	}

	TEST(Area should be calculated for a rectangle: 2.128*3.123=6.61)
	{
		TypeLength length(2.128);
		TypeLength width(3.123);
		Rectangle rectangle(length,width);
		ASSERT_EQ(6.61, rectangle.getArea());
	}

	TEST(Area should be calculated for a rectangle: 2.163*3.128=6.74)
	{
		TypeLength length(2.163);
		TypeLength width(3.128);
		Rectangle rectangle(length,width);
		ASSERT_EQ(6.74, rectangle.getArea());
	}

	TEST(Area should be calculated for a invalid rectangle: 100.163*100.128=0)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(Area should be calculated for a invalid rectangle: 100.163*100.128=0)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		TypeLength newLength(2.163);
		rectangle.setLength(newLength);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(Area should be calculated for a invalid rectangle: 100.163*100.128=0)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		TypeLength newWidth(3.128);
		rectangle.setWidth(newWidth);
		ASSERT_EQ(0, rectangle.getArea());
	}

	TEST(Area should be calculated for a rectangle: 100.163*100.128=0)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		TypeLength newLength(2.163);
		TypeLength newWidth(3.128);
		rectangle.setLength(newLength);
		rectangle.setWidth(newWidth);
		ASSERT_EQ(6.74, rectangle.getArea());
	}

	TEST(Perimeter should be calculated for a rectangle: 2*(2.123+3.128)=10.48)
	{
		TypeLength length(2.123);
		TypeLength width(3.128);
		Rectangle rectangle(length,width);
		ASSERT_EQ(10.48, rectangle.getPerimeter());
	}

	TEST(Perimeter should be calculated for a rectangle: 2*(2.165+3.128)=10.56)
	{
		TypeLength length(2.165);
		TypeLength width(3.128);
		Rectangle rectangle(length,width);
		ASSERT_EQ(10.56, rectangle.getPerimeter());
	}

	TEST(Perimeter should be calculated for a invalid rectangle: 2*(100.163+100.128)=0)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(Perimeter should be calculated for a invalid rectangle: 2*(100.163+100.128)=0)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		TypeLength newLength(2.165);
		rectangle.setLength(newLength);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(Perimeter should be calculated for a invalid rectangle: 2*(100.163+100.128)=0)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		TypeLength newWidth(3.128);
		rectangle.setWidth(newWidth);
		ASSERT_EQ(0, rectangle.getPerimeter());
	}

	TEST(Perimeter should be calculated for a repaired rectangle: 2*(100.163+100.128)=10.59)
	{
		TypeLength length(100.163);
		TypeLength width(100.128);
		Rectangle rectangle(length,width);
		TypeLength newLength(2.165);
		TypeLength newWidth(3.128);
		rectangle.setLength(newLength);
		rectangle.setWidth(newWidth);
		ASSERT_EQ(10.56, rectangle.getPerimeter());
	}
};
